package main

import "fmt"

// 使用管道作为函数参数时，可以指定管道只用于接收还是发送

func ping(pings chan<- string, msg string) {
	pings <- msg
}

func pong(pings <-chan string, pongs chan<- string) {
	strings := <-pings
	pongs <- strings
}
func main() {
	pings := make(chan string, 1)
	pongs := make(chan string, 1)
	ping(pings, "消息1")
	pong(pings, pongs)
	fmt.Println(<-pongs)
}
